import fs from "fs"
import YAML from 'yaml'

class Yaml {
    constructor() {
    }

    // 读
    read(path) {
        try {
            return YAML.parse(fs.readFileSync(path, 'utf8'));
        } catch (e) {
            console.log(e);
            return false;
        }
    }

    // 写
    write(path, data) {
        try {
            fs.writeFileSync(path, YAML.stringify(data), 'utf8');
            return true
        } catch (e) {
            console.log(e);
            return false
        }
    }
}

export default new Yaml()
